<template>
  <div class="app-container">
    <el-card>
      <el-row>

        <el-col :span="5">
          <activityTree ref="linkConfig" @getFiledList="getList"></activityTree>
        </el-col>
        <el-col :span="18">
          <el-card>
            <el-card>
              <div slot="header" class="clearfix">
                <span>搜索</span>
                <el-button style="float: right; padding: 3px 0" type="text" @click="$message.success('彭总:好的')">彭总v我50</el-button>
              </div>
              <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="10em">
                <el-row>
                <el-form-item label="免息券抢券日期" prop="presetTime">
                  <el-date-picker
                    v-model="queryParams.presetTimes"
                    type="daterange"
                    align="right"
                    unlink-panels
                    range-separator="至"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期"
                    value-format="yyyy-MM-dd"
                    :picker-options="pickerOptions">
                  </el-date-picker>
                  <!--            <el-date-picker clearable
                                              v-model="queryParams.presetTime"
                                              type="date"
                                              value-format="yyyy-MM-dd"
                                              placeholder="请选择免息券抢券日期">
                              </el-date-picker>-->
                </el-form-item>
                <el-form-item label="所有者" prop="ownerUserId">
                  <el-select v-model="queryParams.ownerUserId" placeholder="请选择" clearable size="small">
                    <el-option label="sitia" :value="1" />
                    <el-option label="林文龙" :value="6" />
                    <el-option label="彭锦鹏" :value="7" />
                  </el-select>
                </el-form-item>
                </el-row>
                <el-row>
                  <div class="text-center">
                    <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">查询数据</el-button>
                    <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
                  </div>
                </el-row>
              </el-form>
            </el-card>
            <el-card style="margin-top: 1em;margin-bottom: 1em">
              <div slot="header" class="clearfix">
                <span>统计</span>
                <el-button style="float: right; padding: 3px 0" type="text" @click="queryData">刷新</el-button>
              </div>

              <el-row :gutter="20">
                <el-col :span="4">
                  <div>
                    <el-statistic
                      :value="count.validCount"
                      title="有效订单量"
                    ></el-statistic>
                  </div>
                </el-col>
                <el-col :span="5">
                  <div>
                    <el-statistic
                      group-separator=","
                      :precision="2"
                      :value="count.validPrice"
                      title="有效订单佣金"
                    ></el-statistic>
                  </div>
                </el-col>
                <el-col :span="4">
                  <div>
                    <el-statistic

                      :value="count.finishCount"
                      title="完成订单量"
                    >
                      <template slot="prefix">
                        <i class="el-icon-s-flag" style="color: red"></i>
                      </template>
                      <template slot="suffix">
                        <i class="el-icon-s-flag" style="color: blue"></i>
                      </template>
                    </el-statistic>
                  </div>
                </el-col>
                <el-col :span="5">
                  <div>
                    <el-statistic
                      group-separator=","
                      :precision="2"
                      decimal-separator="."
                      :value="count.finishPrice"
                      title="预估收入"
                    >
                      <template slot="prefix">
                        <i class="el-icon-s-flag" style="color: red"></i>
                      </template>
                      <template slot="suffix">
                        <i class="el-icon-s-flag" style="color: blue"></i>
                      </template>
                    </el-statistic>
                  </div>
                </el-col>
                <el-col :span="5">
                  <div>
                    <el-statistic
                      group-separator=","
                      :precision="2"
                      decimal-separator="."
                      :value="count.finishPrice * rebateTax"
                      title="税后预估佣金"
                    >
                      <template slot="prefix">
                        <i class="el-icon-s-flag" style="color: red"></i>
                      </template>
                      <template slot="suffix">
                        <i class="el-icon-s-flag" style="color: blue"></i>
                      </template>
                    </el-statistic>
                  </div>
                </el-col>
              </el-row>
              <!-- 折线图容器 -->
              <div id="lineChart" ref="lineChart" style="width: 100%; height: 400px;"></div>
<!--
              <div id="pieChart" ref="pieChart"  style="width: 100%"></div>-->
            </el-card>

            <el-row :gutter="10" class="mb8">
              <!--      <el-col :span="1.5">
                      <el-button
                        type="primary"
                        plain
                        icon="el-icon-plus"
                        size="mini"
                        @click="handleAdd"
                        v-hasPermi="['jd:order:add']"
                      >新增</el-button>
                    </el-col>
                    <el-col :span="1.5">
                      <el-button
                        type="success"
                        plain
                        icon="el-icon-edit"
                        size="mini"
                        :disabled="single"
                        @click="handleUpdate"
                        v-hasPermi="['jd:order:edit']"
                      >修改</el-button>
                    </el-col>-->
              <el-col :span="1.5">
                <el-button
                  type="danger"
                  plain
                  icon="el-icon-delete"
                  size="mini"
                  :disabled="multiple"
                  @click="handleDelete"
                  v-hasPermi="['jd:order:remove']"
                >删除</el-button>
              </el-col>
              <el-col :span="1.5">
                <el-button
                  type="warning"
                  plain
                  icon="el-icon-download"
                  size="mini"
                  @click="handleExport"
                  v-hasPermi="['jd:order:export']"
                >导出</el-button>
              </el-col>
              <el-button type="primary"
                         size="mini"
                         @click="OpenImportOrders"
                         v-hasPermi="['jd:order:export']">
                导入订单数组
                <i class="el-icon-upload el-icon--right"/>
              </el-button>
              <el-button type="success"
                         size="mini"
                         icon="el-icon-upload2"
                         @click="importJinFenOpen =true"
                         v-hasPermi="['jd:order:export']">
                导入京粉csv文件
              </el-button>
              <!--      <el-button
                      type="warning"
                      plain
                      icon="el-icon-download"
                      size="mini"
                      @click="OpenImportOrders"
                      v-hasPermi="['jd:order:export']"
                    >导入订单数组</el-button>-->
              <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
            </el-row>

            <el-table v-loading="loading" :data="orderList" @selection-change="handleSelectionChange">
              <el-table-column type="selection" width="55" align="center" />
              <!--      <el-table-column label="订单表id" align="center" prop="mxOrderId" />
                    <el-table-column label="订单数组" align="center" prop="jdOrders" />-->
              <el-table-column label="京东订单号" align="center" prop="orderId" width="120">
                <template slot-scope="scope">
                  <el-popover
                    placement="top-start"
                    title="京东订单号"
                    width="120"
                    trigger="hover"
                    :content="scope.row.orderId">
                    <p class="table2" slot="reference">
                      {{scope.row.orderId}}
                    </p>
                  </el-popover>
                </template>
              </el-table-column>
              <!--      <el-table-column label="下单用户是否为PLUS会员 0：否，1：是" align="center" prop="plus" />
                    <el-table-column label="商品ID" align="center" prop="skuId" />
                    <el-table-column label="推客ID" align="center" prop="unionId" />-->
              <el-table-column label="商品名称" align="center" prop="skuName" >
                <template slot-scope="scope">
                  <el-popover
                    placement="top-start"
                    title="商品名称"
                    width="120"
                    trigger="hover"
                    :content="scope.row.skuName">
                    <p class="table2" slot="reference">
                      {{scope.row.skuName}}
                    </p>
                  </el-popover>
                </template>
              </el-table-column>
              <el-table-column label="商品数量" align="center" prop="skuNum" />
              <el-table-column label="商品已退货数量" align="center" prop="skuReturnNum" />
              <el-table-column label="商品售后中数量" align="center" prop="skuFrozenNum" />
              <el-table-column label="商品单价" align="center" prop="price" />
              <el-table-column label="佣金比例" align="center" prop="commissionRate" />
              <!--      <el-table-column label="分成比例" align="center" prop="subsideRate" />
                    <el-table-column label="补贴比例" align="center" prop="subsidyRate" />
                    <el-table-column label="最终分佣比例" align="center" prop="finalRate" />-->
              <!--      <el-table-column label="预估计佣金额" align="center" prop="estimateCosPrice" />-->
              <el-table-column label="预估佣金" align="center" prop="estimateFee" />
              <el-table-column label="实际计佣金额" align="center" prop="actualCosPrice" />
              <el-table-column label="实际佣金" align="center" prop="actualFee" />
              <!--      <el-table-column label="sku维度的有效码" align="center" prop="validCode" />
                    <el-table-column label="下单时间,格式yyyy-MM-dd HH:mm:ss完成时间" align="center" prop="orderTime" />
                    <el-table-column label="完成时间" align="center" prop="finishTime" />
                    <el-table-column label="更新时间,格式yyyy-MM-dd HH:mm:ss" align="center" prop="modifyTime" />
                    <el-table-column label="发货状态" align="center" prop="expressStatus" />
                    <el-table-column label="联盟商品ID" align="center" prop="itemId" />-->
              <!--      <el-table-column label="该订单归属人" align="center" prop="ownerUserId" />-->
              <el-table-column label="该订单归属人姓名" align="center" prop="ownerUserName" />
              <!--      <el-table-column label="订单京粉所属人" align="center" prop="jingfenBy" />-->
              <el-table-column label="订单京粉所属人姓名" align="center" prop="jingfenName" />
              <!--      <el-table-column label="状态" align="center" prop="status" />-->
              <el-table-column label="税后佣金" align="center" prop="commission">
                <template slot-scope="scope">
                  {{scope.row.actualFee?(scope.row.actualFee * rebateTax).toFixed(3):scope.row.actualFee}}
                </template>
              </el-table-column>
              <el-table-column label="订单状态" align="center" prop="ext1" />
              <!--      <el-table-column label="扩展字段2" align="center" prop="ext2" />
                    <el-table-column label="备注" align="center" prop="remark" />-->
              <el-table-column label="免息券抢券日期" align="center" prop="presetTime" width="180">
                <template slot-scope="scope">
                  <span>{{ parseTime(scope.row.presetTime, '{y}-{m}-{d}') }}</span>
                </template>
              </el-table-column>
              <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                <template slot-scope="scope">
                  <el-button
                    size="mini"
                    type="text"
                    icon="el-icon-s-fold"
                    @click="openDetail(scope.row)"
                  >详细</el-button>
                  <el-button
                    size="mini"
                    type="text"
                    icon="el-icon-edit"
                    @click="handleUpdate(scope.row)"
                    v-hasPermi="['jd:order:edit']"
                  >修改</el-button>
                  <!--          <el-button
                              size="mini"
                              type="text"
                              icon="el-icon-delete"
                              @click="handleDelete(scope.row)"
                              v-hasPermi="['jd:order:remove']"
                            >删除</el-button>-->
                </template>
              </el-table-column>
            </el-table>

            <pagination
              v-show="total>0"
              :total="total"
              :page.sync="queryParams.pageNum"
              :limit.sync="queryParams.pageSize"
              @pagination="getList"
            />
          </el-card>
        </el-col>
      </el-row>
    </el-card>



    <!-- 添加或修改返利订单对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="订单表id" prop="mxOrderId">
          <el-input v-model="form.mxOrderId" placeholder="请输入订单表id" />
        </el-form-item>
        <el-form-item label="订单数组" prop="jdOrders">
          <el-input v-model="form.jdOrders" placeholder="请输入订单数组" />
        </el-form-item>
        <el-form-item label="京东订单号(从数组中确认的订单号)" prop="orderId">
          <el-input v-model="form.orderId" placeholder="请输入京东订单号(从数组中确认的订单号)" />
        </el-form-item>
        <el-form-item label="下单用户是否为PLUS会员 0：否，1：是" prop="plus">
          <el-input v-model="form.plus" placeholder="请输入下单用户是否为PLUS会员 0：否，1：是" />
        </el-form-item>
        <el-form-item label="商品ID" prop="skuId">
          <el-input v-model="form.skuId" placeholder="请输入商品ID" />
        </el-form-item>
        <el-form-item label="推客ID" prop="unionId">
          <el-input v-model="form.unionId" placeholder="请输入推客ID" />
        </el-form-item>
        <el-form-item label="商品名称" prop="skuName">
          <el-input v-model="form.skuName" placeholder="请输入商品名称" />
        </el-form-item>
        <el-form-item label="商品数量" prop="skuNum">
          <el-input v-model="form.skuNum" placeholder="请输入商品数量" />
        </el-form-item>
        <el-form-item label="商品已退货数量" prop="skuReturnNum">
          <el-input v-model="form.skuReturnNum" placeholder="请输入商品已退货数量" />
        </el-form-item>
        <el-form-item label="商品售后中数量" prop="skuFrozenNum">
          <el-input v-model="form.skuFrozenNum" placeholder="请输入商品售后中数量" />
        </el-form-item>
        <el-form-item label="商品单价" prop="price">
          <el-input v-model="form.price" placeholder="请输入商品单价" />
        </el-form-item>
        <el-form-item label="佣金比例(投放的广告主计划比例)" prop="commissionRate">
          <el-input v-model="form.commissionRate" placeholder="请输入佣金比例(投放的广告主计划比例)" />
        </el-form-item>
        <el-form-item label="分成比例" prop="subsideRate">
          <el-input v-model="form.subsideRate" placeholder="请输入分成比例" />
        </el-form-item>
        <el-form-item label="补贴比例" prop="subsidyRate">
          <el-input v-model="form.subsidyRate" placeholder="请输入补贴比例" />
        </el-form-item>
        <el-form-item label="最终分佣比例" prop="finalRate">
          <el-input v-model="form.finalRate" placeholder="请输入最终分佣比例" />
        </el-form-item>
        <el-form-item label="预估计佣金额：由订单的实付金额拆分至每个商品的预估计佣金额，不包括运费，以及京券、东券、E卡、余额等虚拟资产支付的金额。该字段仅为预估值，实际佣金以actualCosPrice为准进行计算" prop="estimateCosPrice">
          <el-input v-model="form.estimateCosPrice" placeholder="请输入预估计佣金额：由订单的实付金额拆分至每个商品的预估计佣金额，不包括运费，以及京券、东券、E卡、余额等虚拟资产支付的金额。该字段仅为预估值，实际佣金以actualCosPrice为准进行计算" />
        </el-form-item>
        <el-form-item label="推客的预估佣金" prop="estimateFee">
          <el-input v-model="form.estimateFee" placeholder="请输入推客的预估佣金" />
        </el-form-item>
        <el-form-item label="实际计算佣金的金额。订单完成后，会将误扣除的运费券金额更正。如订单完成后发生退款，此金额会更新。" prop="actualCosPrice">
          <el-input v-model="form.actualCosPrice" placeholder="请输入实际计算佣金的金额。订单完成后，会将误扣除的运费券金额更正。如订单完成后发生退款，此金额会更新。" />
        </el-form-item>
        <el-form-item label="推客分得的实际佣金" prop="actualFee">
          <el-input v-model="form.actualFee" placeholder="请输入推客分得的实际佣金" />
        </el-form-item>
        <el-form-item label="sku维度的有效码" prop="validCode">
          <el-input v-model="form.validCode" placeholder="请输入sku维度的有效码" />
        </el-form-item>
        <el-form-item label="下单时间,格式yyyy-MM-dd HH:mm:ss完成时间" prop="orderTime">
          <el-input v-model="form.orderTime" placeholder="请输入下单时间,格式yyyy-MM-dd HH:mm:ss完成时间" />
        </el-form-item>
        <el-form-item label="完成时间" prop="finishTime">
          <el-input v-model="form.finishTime" placeholder="请输入完成时间" />
        </el-form-item>
        <el-form-item label="更新时间,格式yyyy-MM-dd HH:mm:ss" prop="modifyTime">
          <el-input v-model="form.modifyTime" placeholder="请输入更新时间,格式yyyy-MM-dd HH:mm:ss" />
        </el-form-item>
        <el-form-item label="联盟商品ID" prop="itemId">
          <el-input v-model="form.itemId" placeholder="请输入联盟商品ID" />
        </el-form-item>
        <el-form-item label="该订单归属人" prop="ownerUserId">
          <el-input v-model="form.ownerUserId" placeholder="请输入该订单归属人" />
        </el-form-item>
        <el-form-item label="该订单归属人姓名" prop="ownerUserName">
          <el-input v-model="form.ownerUserName" placeholder="请输入该订单归属人姓名" />
        </el-form-item>
        <el-form-item label="订单京粉所属人" prop="jingfenBy">
          <el-input v-model="form.jingfenBy" placeholder="请输入订单京粉所属人" />
        </el-form-item>
        <el-form-item label="订单京粉所属人姓名" prop="jingfenName">
          <el-input v-model="form.jingfenName" placeholder="请输入订单京粉所属人姓名" />
        </el-form-item>
        <el-form-item label="佣金" prop="commission">
          <el-input v-model="form.commission" placeholder="请输入佣金" />
        </el-form-item>
        <el-form-item label="扩展字段1" prop="ext1">
          <el-input v-model="form.ext1" placeholder="请输入扩展字段1" />
        </el-form-item>
        <el-form-item label="扩展字段2" prop="ext2">
          <el-input v-model="form.ext2" placeholder="请输入扩展字段2" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" placeholder="请输入备注" />
        </el-form-item>
        <el-form-item label="免息券抢券日期" prop="presetTime">
          <el-date-picker clearable
                          v-model="form.presetTime"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择免息券抢券日期">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <import-orders ref="importOrders" :open=importOrdersOpen @getList="getList" @close="importOrdersOpen =false"></import-orders>

    <import-jin-fen-csv ref="importJinFenCsv" :open=importJinFenOpen @getList="getList" @close="importJinFenOpenClose"/>
    <detail ref="detail" :open=detailOpen :form="detailForm" @getList="getList" @close="closeDetail"/>
  </div>
</template>

<script>
import {
  listOrder,
  delOrder,
  addOrder,
  updateOrder,
  pageList,
  queryRebatePie,
  rebateStatistics, getRebateOrder, rebateChart
} from '@/api/mx/rebate'
import  importOrders from './importOrders'
import  importJinFenCsv from './importJinFenCsv'
import  statistics from './statistics'
import  detail from './detail'
import  activityTree from './activityTree'
import * as echarts from "echarts";
import { getOrder } from '@/api/mx/order'
export default {
  name: "Order",
  components: {
    importOrders,importJinFenCsv,statistics,detail,activityTree
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 返利订单表格数据
      orderList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      importOrdersOpen: false,
      importJinFenOpen: false,
      detailOpen: false,//详细页面
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        mxOrderId: null,
        jdOrders: null,
        orderId: null,
        plus: null,
        skuId: null,
        unionId: null,
        skuName: null,
        skuNum: null,
        skuReturnNum: null,
        skuFrozenNum: null,
        price: null,
        commissionRate: null,
        subsideRate: null,
        subsidyRate: null,
        finalRate: null,
        estimateCosPrice: null,
        estimateFee: null,
        actualCosPrice: null,
        actualFee: null,
        validCode: null,
        orderTime: null,
        finishTime: null,
        modifyTime: null,
        expressStatus: null,
        itemId: null,
        ownerUserId: null,
        ownerUserName: null,
        jingfenBy: null,
        jingfenName: null,
        status: null,
        commission: null,
        ext1: null,
        ext2: null,
        presetTime: null,
        presetTimes: [],
        all: null
      },
      orderId: null,//查看详细订单的id
      // 表单参数
      form: {},
      detailForm: {},
      // 表单校验
      rules: {},
      pickerOptions: {
        shortcuts: [{
          text: '最近一周',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近一个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近三个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
            picker.$emit('pick', [start, end]);
          }
        }]
      },
      date: [new Date(2000, 10, 10, 10, 10), new Date(2000, 10, 11, 10, 10)],
      like: true,
      value1: 4154.564,
      value2: 1314,
      //title: "今日佣金",
      query: {},
      PieInfo: [],
      count: {
        validCount: 0,
        validPrice: 0,
        finishCount: 0,
        finishPrice: 0,
      },
      rebateTax: 1,
      // ECharts实例对象
      lineChartInstance: null,
      lineChartData: {
        xAxis: {
          data: []
        },
        yAxis: {},
        series: [
          {
            data: [],
            type: 'line',
            label: {
              show: true,
              position: 'bottom',
              textStyle: {
                fontSize: 20
              }
            }
          }
        ]
      },
    }
  },
  created() {
    //this.getList();
    this.getConfigKey("rebateTax").then(response => {
      this.rebateTax = response.msg;
    });
  },
  mounted() {
    //this.queryData()
    this.initLineChart();
  },
  methods: {
    /** 查询返利订单列表 */
    getList(startTime,endTime) {
      if (startTime && endTime) {
        this.queryParams.presetTimes = [startTime, endTime]
      }
      this.loading = true;
      pageList(this.queryParams).then(response => {
        this.orderList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
      this.queryStatistics()
      this.updateLineChartData()
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        mxOrderId: null,
        jdOrders: null,
        orderId: null,
        plus: null,
        skuId: null,
        unionId: null,
        skuName: null,
        skuNum: null,
        skuReturnNum: null,
        skuFrozenNum: null,
        price: null,
        commissionRate: null,
        subsideRate: null,
        subsidyRate: null,
        finalRate: null,
        estimateCosPrice: null,
        estimateFee: null,
        actualCosPrice: null,
        actualFee: null,
        validCode: null,
        orderTime: null,
        finishTime: null,
        modifyTime: null,
        expressStatus: null,
        itemId: null,
        ownerUserId: null,
        ownerUserName: null,
        jingfenBy: null,
        jingfenName: null,
        status: null,
        commission: null,
        ext1: null,
        ext2: null,
        remark: null,
        presetTime: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        all: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加返利订单";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getRebateOrder(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改返利订单";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateOrder(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addOrder(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除返利订单编号为"' + ids + '"的数据项？').then(function() {
        return delOrder(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('jd/order/export', {
        ...this.queryParams
      }, `order_${new Date().getTime()}.xlsx`)
    },
    /**
     * 打开导入订单id界面
     * @constructor
     */
    OpenImportOrders(){
      console.log("打开哦")
      this.importOrdersOpen = true
      console.log(this.importOrdersOpen )
    },
    importJinFenOpenClose(){
      this.importJinFenOpen = false
      this.getList();
    },
    opens(){
      this.$nextTick(() => {
        this.pie1();
      })
    },
    pie1(){
      this.completes = echarts.init(this.$refs.pieChart,"analyse");
      this.completes.setOption({
        title:{
          text:"完成情况"
        },
        tooltip: {
          trigger: "item",
          formatter: "{a} <br/>{b} : {c} ({d}%)",
        },
        color: ['#f56c6c','#6DC8EC', '#3F8FFF'],
        legend: {
          orient: 'vertical',
          icon: 'circle',
          align: 'left',
          x: 'right',
          y: 'bottom',
          data: ['已完成', '未完成']
        },
        series: [
          {
            name: "完成率",
            type: "pie",
            radius: '50%',
            center: ["50%", "38%"],
            data:this.PieInfo,
            avoidLabelOverlap:false,
            animationEasing: "cubicInOut",
            animationDuration: 1000,
          }
        ]
      });

    },

    queryData(){
      queryRebatePie(this.queryParams).then(res=>{
        if (res.code === 200) {
          this.PieInfo = res.data
          this.opens()
          console.log(this.PieInfo)
        }
      })
    },
    queryStatistics(){
      rebateStatistics(this.queryParams).then(res=>{
        if (res.code === 200) {
          this.count = res.data
          console.log(this.count)

        }
      })
    },
    /**
     * 打开详细页
     * @param row
     */
    openDetail(row) {
      this.orderId = row.mxOrderId
      getOrder(row.mxOrderId).then(response => {
        if (response.code === 200) {
          this.detailForm = response.data;
          this.detailOpen = true
        }
      });
    },
    closeDetail() {
      this.detailOpen = false
      this.detailForm = {}
    },
    /**
     * 折线图
     */
    // 初始化折线图
    initLineChart() {
      this.lineChartInstance = echarts.init(this.$refs.lineChart);
      this.lineChartInstance.setOption(this.lineChartData);
    },

    // 查询数据等其他方法...

    // 当数据更新时，重新设置ECharts的option
    updateLineChartData() {
      // 这里根据实际情况更新lineChartData数据
      // 然后调用setOption方法更新图表
      rebateChart(this.queryParams).then(res=>{
        if (res.code == 200) {
          this.lineChartInstance.setOption({
            series: [
              {
                data: res.data.values,
              },

            ],
            xAxis: {
              data: res.data.labels
            }
          });
        }
      })

    },

  }
};
</script>

<style scoped>
.table2  {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

.demo-table-expand label {
  width: 90px;
  color: #99a9bf;
}
.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 30%;
}
</style>
